package com.hyopt.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.hyopt.common.utils.SmsConstant;
import com.hyopt.modules.app.dao.SmsDao;
import com.hyopt.modules.app.entity.Sms;
import com.hyopt.modules.app.service.SmsService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;

/**
 * @author ：Li9527
 * @date ：Created in 2019-09-16 14:15
 * @description：${description}
 * @modified By：
 * @version: 1.0.0
 */
@Service
public class SmsServiceImpl extends ServiceImpl<SmsDao, Sms> implements SmsService {

    @Override
    public boolean sendSms(String phone, int templId, ArrayList<String> params) {
        try {
            SmsSingleSender ssender = new SmsSingleSender(SmsConstant.appid, SmsConstant.appkey);
            SmsSingleSenderResult result = ssender.sendWithParam("86", phone,
                    templId, params, SmsConstant.smsSign, "", "");
            System.out.println(result);
            if (result != null && result.result == 0){
                return true;
            }else{
                return false;
            }
        } catch (Exception e) {
            return false;
        }
    }

}
